<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title>到货预报</title>
		<link rel="stylesheet" type="text/css" href="btn_class.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/resources/css/ext-all.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/ext-2.2/style.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/ext-2.2/desktop.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/ext-2.2/ext-patch.css" />

		<script type="text/javascript" src="ext-2.2/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="ext-2.2/ext-all.js"></script>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

		<script type="text/javascript">
		<%String uId = (String) session.getAttribute("Uid");
			if (uId == null || uId.equals("null")) {%>
			window.parent.location.href = 'index.jsp';
		<%}%>
		
		window.onload = function(){
			if("<%=request.getAttribute("enterWbFlag")%>"=="Y")
			{
				alert("到货预报操作成功！");
			}
			if("<%=request.getAttribute("enterWbFlag")%>"=="N")
			{
				alert("输入错误,请重新输入或联系客服！");
			}
				if("<%=request.getAttribute("enterWbFlag")%>"=="dup")
			{
				alert("对不起,该订单已经输入 !");
			}
		}
		  

		
			function clearContent()
			{
				document.getElementById("wbUps").value = "";
				document.getElementById("wbEnterWeight").value = "";
				document.getElementById("wbArea").value = "CA";
			}


			 function clearNoNum(obj)
			    {
			        //先把非数字的都替换掉，除了数字和.
			        obj.value = obj.value.replace(/[^\d.]/g,"");
			        //必须保证第一个为数字而不是.
			        obj.value = obj.value.replace(/^\./g,"");
			        //保证只有出现一个.而没有多个.
			        obj.value = obj.value.replace(/\.{2,}/g,".");
			        //保证.只出现一次，而不能出现两次以上
			        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
			    }
						
			function enterWaybill()
			{
				var wbUps = document.getElementById("wbUps").value;
				var wbEnterWeight = document.getElementById("wbEnterWeight").value;
				var regu =/^[A-Za-z0-9]+$/;
				var re = new RegExp(regu); 
				if (!re.test(wbUps)) { 
					alert("请输入正确的运单号,只允许字母和数字!");
					return; 
				}
				
				if(wbUps=="")
				{
					alert("运单号不能为空");
					return;
				}
				if(wbEnterWeight=="")
				{
					alert("重量不能为空");
					return;
				}

		   		 Ext.Ajax.request({ 
		             //请求地址 
		             url: 'waybill!checkWaybillExist.do', 
		             //提交参数组 
		             params: { 
		                 wbUps : Ext.get('wbUps').dom.value.trim()
		             }, 
		             //成功时回调 
		             success: function(response, options) { 
		                //获取响应的json字符串 
		               var responseArray = Ext.util.JSON.decode(response.responseText);                                               
		                    if(responseArray.success==true){ 
		                    	var f = document.forms["enterWaybillForm"];
		        				f.action = "waybill!forecastWaybill.do";
		        				f.submit();
		                    } 
		                    else{ 
		                    	alert("对不起,该快递号已经存在!");
		    			   		return;
		                    } 
		            } 
		   		 }); 
		   		 
			}
			function enterToWaybill()
			{
				if (event.keyCode == 13)
				{
					 enterWaybill();
				}
			}

	</script>
	</head>

	
<body style="background:white"> 
	<div class="x-panel-header x-panel-header-noborder x-unselectable" id="ext-gen8" style="mozuserselect: none; khtmluserselect: none;" unselectable="on">
		<span class="x-panel-header-text" >到货预报</span>
	</div>
		<form name="enterWaybillForm" method="post">
		 <table width="300px" border="0" cellSpacing="3" cellPadding="3">
		 	<tr>
		 		<td align="right"><font style="font-size:15px">运单号：</font></td>
		 		<td align="left"><input name="wbUps" id="wbUps" size="25" /><font color="#ff0000">*</font></td>
		 	</tr>
		 	<tr>
		 		<td align="right"><font style="font-size:15px">重量：</font></td>
		 		<td align="left"><input name="wbEnterWeight" onkeyup="clearNoNum(this)" id="wbEnterWeight" size="25"/><font color="#ff0000">Lbs*</font></td>
		 	</tr>
		 	<tr>
		 		<td align="right"><font style="font-size:15px">仓库：</font></td>
		 		<td align="left">
		 		<select name="wbArea" id="wbArea" style="width:185px">
  						<option value ="CA">CA</option>
  						<option value ="OR">OR</option>
  						<option value ="NK">New York</option>
				</select>
				<font color="#ff0000">*</font>
				</td>
		 	</tr>
		 
		 	<tr>
		 		<td align="center">
		 			<input  type="button" class="submit_btn"  onclick="enterWaybill();" value="录入" />
		 		</td>
		 		<td align="center">
		 			<input  type="button" class="submit_btn"  onclick="clearContent();" value="重置" />
		 		</td>
		 	</tr>
		 	
		 </table>
		  
           </form>
    </body> 
</html>
